package com.gthncz;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.gthncz.beans.StudentMarks;
import com.gthncz.beans.StudentMarksDAO;

public class TransactionDemo {

	public static void main(String[] args) {
		// ApplicationContext context = new ClassPathXmlApplicationContext("Beans_transaction.xml");
		// StudentMarkDAOImpl studentMarkDAOImpl = (StudentMarkDAOImpl) context.getBean("studentMarkDAOImpl");
		ApplicationContext context = new ClassPathXmlApplicationContext("Beans_transaction2.xml");
		StudentMarksDAO studentMarkDAOImpl = (StudentMarksDAO) context.getBean("studentMarkDAOImpl");
		
		System.out.println("-------------Insert Students-------------");
		studentMarkDAOImpl.insert("Alice", 18, 80, 2019);
		studentMarkDAOImpl.insert("Bob", 20, 82, 2019);
		studentMarkDAOImpl.insert("carol", 20, 85, 2019);
		studentMarkDAOImpl.insert("Dave", 21, 86, 2019);
		studentMarkDAOImpl.insert("frank", 22, 90, 2019);
		
		System.out.println("-------------ALl Students-------------");
		List<StudentMarks> studentMarks = studentMarkDAOImpl.listStudents();
		for (StudentMarks marks : studentMarks) {
			System.out.println(marks.toString());
		}
		System.out.println("---------------------------------------");
	}

}
